package com.douguo.recipe;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.widget.ProgressBar;
import android.widget.Toast;

import com.douguo.recipe.sina.Cache;
import com.douguo.recipe.sina.RequestToken;
import com.douguo.recipe.sina.WeiboHelper;
import com.douguo.recipe.sina.WeiboHttpClient.WeiboResponseCallBack;
/**
 * 这个Activity是oauth返回时回调的Activity
 * @author zuozp
 *
 */
public class OAuthActivity extends DouguoActivity{
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		Uri uri = this.getIntent().getData();
		
		String pin = uri.getQueryParameter("oauth_verifier");
		WeiboResponseCallBack callBack = (WeiboResponseCallBack) Cache.remove(WeiboHelper.WEIBO_OAUTH_CALLBACK_KEY);
		RequestToken requestToken = (RequestToken) Cache.remove("requestToken");
		WeiboHelper.reqAccessToken(this, requestToken, pin, callBack);
		
		Activity carActivity = (Activity) Cache.getCache(WeiboHelper.WEIBO_CAR_ACTIVITY_KEY);
		
		Toast.makeText(getApplicationContext(), "正在将您分享的内容发送至新浪微博，可以继续浏览其他内容", 1000).show();
		
		Intent intent = new Intent(this, carActivity.getClass());
		intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
		startActivity(intent);
		
		this.finish();
	}

}
